class House:
  # 构造函数
  def __init__(self, h_type, h_area):
    self.h_type = h_type
    self.h_area = h_area
    self.furniture_list = []
    self.remain_area = h_area
  # 添加家具
  def addFurniture(self, furniture):
    # 判断剩余的总面积是否足够放
    if self.remain_area >= furniture.f_area:
      # 把家具放入列表中
      self.furniture_list.append(furniture.f_name)
      #更新剩余面积
      self.remain_area -= furniture.f_area
      print(f"{furniture.f_name}已成功添加！")
    else:
      print(f"无法添加{furniture.f_name}")

  # 显示房子当前信息
  def display(self):
    '''
    户型，总面积，剩余面积，家具名称列表
    '''
    print(f"房屋户型为{self.h_type}")
    print(f"总面积为{self.h_area}")
    print(f"剩余面积{self.remain_area}")
    # for i in range(len(self.furniture_list)):
    print(f"家具列表为{self.furniture_list}")




class Furniture:
  def __init__(self, f_name, f_area):
    self.f_name = f_name
    self.f_area = f_area

# 创建对象
house1 = House("A", 30)
f1 = Furniture("床", 4)
f2 = Furniture("衣柜", 2)
f3 = Furniture("餐桌", 1.5)
house1.addFurniture(f1)
house1.addFurniture(f2)
house1.addFurniture(f3)

house1.display()









